package cn.ujn.edu.microservice01mq.controller;

import cn.ujn.edu.microservice01mq.entity.User;
import cn.ujn.edu.microservice01mq.service.IUserService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: shzhu
 * @Date: 2024/11/7 20:52
 * @Description:
 */
@RestController("/user")
@RequiredArgsConstructor
public class UserController {
    private final IUserService userService;

    @GetMapping("/{id}")
    public User selectUserById(@PathVariable("id") Long id){
       return userService.getById(id);
    }
    //  测试增加余额
    @PutMapping("/{id}/incre/{amount}")
   public void  incrementBalance(@PathVariable("id") Long id,@PathVariable("amount") double amount){
        userService.incrementBalance(id,amount);
   }

}
